package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.TypeValueData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 键值对，类型数据，多条数据，比如班级的班主任，学员的联系人 Mapper 接口
 * </p>
 *
 * @author min
 * @since 2022-11-01
 */
public interface TypeValueDataMapper extends BaseMapper<TypeValueData> {

    @Select("SELECT type_value_data.* ,student.`name` as student_name FROM type_value_data INNER JOIN student ON student.id = for_id WHERE student.deleted = 0 and type_value_data.content = '${content}' AND type_value_data.deleted = 0 GROUP BY for_id")
    List<TypeValueData> getTypeValueData(@Param("content") String content);


    @Select("SELECT COUNT(id) FROM wechars_bind WHERE phone = #{phone}")
    public abstract Integer studentCountByPhone(@Param("phone") String phone);
}
